﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using ZCSBZPJ.Filter;
using ZP.Common;
using ZP.DTO.Common;
using ZP.DTO.ht_type1_title;

namespace ZCSBZPJ.Controllers
{
    public class HTType1TitleController : BaseController
    {
        public ActionResult Index(int ht_id = 0)
        {
            ViewBag.ht_id = ht_id;
            return View();
        }

        [AuthorityFilter]
        /// <summary>
        /// 附件标题-模分页模糊查询
        /// </summary>
        /// <returns></returns>
        public JsonResult GetHTType1Title(ht_type1_titleSearchDTO dto)
        {
            PageModel<ht_type1_titleResultDTO> pageList = new PageModel<ht_type1_titleResultDTO>();
            pageList = _ht_type1_titleService.GetHTType1Title(dto);
            return Json(pageList, JsonRequestBehavior.AllowGet);
        }

        [AuthorityFilter]
        /// <summary>
        /// 保存附件标题-新增/修改
        /// </summary>
        /// <param name="dto"></param>
        /// <returns></returns>
        public JsonResult SaveHTType1Title(ht_type1_titleOperateDTO dto)
        {
            ResultData<string> result = new ResultData<string>();
            try
            {
                UserLoginDTO loginUser = (UserLoginDTO)Session[ZPCommon.SESSION_Login];
                dto.updater = loginUser.account;
                result.SubmitResult = _ht_type1_titleService.SaveHTType1Title(dto);
            }
            catch (Exception e)
            {
                result.SubmitResult = false;
                result.Message = e.Message;
            }
            return Json(result);
        }

        [AuthorityFilter]
        /// <summary>
        /// 删除附件标题
        /// </summary>
        /// <returns></returns>
        public JsonResult DeleteHTType1Title(List<ht_type1_titleOperateDTO> dto)
        {
            ResultData<string> result = new ResultData<string>();
            try
            {
                UserLoginDTO loginUser = (UserLoginDTO)Session[ZPCommon.SESSION_Login];
                result.SubmitResult = _ht_type1_titleService.DeleteHTType1Title(dto, loginUser);
            }
            catch (Exception ex)
            {
                result.SubmitResult = false;
                result.Message = ex.Message;
            }
            return Json(result);
        }
    }
}